﻿using System.Data.Entity.ModelConfiguration;

namespace JHT.EFMigrationTest.ClassLibrary1
{
    internal class StudentsAddressMap : EntityTypeConfiguration<StudentsAddress>
    {
        public StudentsAddressMap()
        {
            ToTable("StudentsAddress");
            HasKey(p => p.StudentsAddressId);
            Property(p => p.StudentsAddressId).HasColumnName("StudentsAddressId").HasColumnType("bigint").IsRequired();
            Property(p=>p.Province).HasColumnName("Province").HasColumnType("varchar").HasMaxLength(50).IsOptional();
            Property(p => p.City).HasColumnName("City").HasColumnType("varchar").HasMaxLength(50).IsOptional();
            Property(p => p.Country).HasColumnName("Country").HasColumnType("varchar").HasMaxLength(50).IsOptional();
            Property(p => p.Address).HasColumnName("Address").HasColumnType("varchar").HasMaxLength(50).IsOptional();
            Property(p => p.ZipCode).HasColumnName("ZipCode").HasColumnType("int").IsOptional();

            HasRequired(p => p.Students).WithOptional(p => p.Address);// 配置一对多或一对0的配置  在附表建立外键关系
        }
    }
}